package com.chendx.store.seckill.controller;

import com.chendx.model.common.dtos.ResponseResult;
import com.chendx.model.seckill.dto.SeckillOrderDto;
import com.chendx.store.api.seckill.SeckillOrderControllerApi;
import com.chendx.store.seckill.service.SeckillOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by chendx on 2022/4/22.
 */
@RestController
@RequestMapping("/api/order")
public class SeckillOrderController implements SeckillOrderControllerApi {

    @Autowired
    private SeckillOrderService seckillOrderService;

    @Override
    @PostMapping("/add")
    public ResponseResult add(@RequestBody SeckillOrderDto dto) {
        return seckillOrderService.add(dto);
    }

    @Override
    @GetMapping("/queryStatus")
    public ResponseResult queryStatus() {
        return seckillOrderService.queryStatus();
    }

    @Override
    @PostMapping("/loadSeckill")
    public ResponseResult loadSeckillOrder(@RequestBody SeckillOrderDto dto) {
        return seckillOrderService.loadOrder(dto);
    }

    @Override
    @GetMapping("/pay")
    public ResponseResult pay() {
        return seckillOrderService.pay();
    }

    @Override
    @GetMapping("/cancel")
    public ResponseResult cancelOrder() {
        return seckillOrderService.cancel();
    }

    @Override
    @GetMapping("/one")
    public ResponseResult one(String id) {

        return seckillOrderService.one(id);
    }
}
